// 创建新得相册

// 获得容器
const createAbBox = document.getElementsByClassName("createAbBox")[0];

// 获得新建相册的按钮
const createAbBtn = document.getElementById("creatABbtn");

// 获得提交按钮
const submitAbTitleBtn = document.getElementById("submitAbTitle");

// 新建相册绑定事件
createAbBtn.onclick = function(){
    createAbBox.style.display = "flex";
    upABimgBox.style.display = "none";
    
    albumDetailBox.style.display = "none"; 
   
    lookAlbumBox.style.display = "none"; 
}



submitAbTitleBtn.onclick = function(){
  
    let abTitleIpt = document.getElementById("createAbIpt").value;
    if(abTitleIpt){
        let data = new FormData();
        data.append("userId",window.userInfoG.data.id);
        data.append("title",abTitleIpt);
        postForm(data,"createAlbum").then( value=>{
            if(value.code == 4000){
                console.log(`新创建的相册ID为${value.msg}`);
                alert(`新创建的相册ID为${value.msg}`);
                lookABbtn.click();
            }
            else{
                console.log("新建相册失败");
            }
        },
        reason=>{
            console.log("AJAX发送创建新相册请求失败");
        });
    }
    else {
        createAbBox.innerHTML = "你输入的标题为空，请重新输入！";
        setTimeout(function(){},1000);
        createAbBox.innerHTML = `<input type="text"  placeholder="请在此处输入一个新的相册的标题" id="createAbIpt">
        <button id="submitAbTitle">提交</button>`;
    }
}